class Solution {
public:
    vector<vector<int>> ret;
    bool check[11] = { false };

    void dfs(vector<int>& nums, vector<int> tmp)
    {
        if(tmp.size() == nums.size())
        {
            ret.push_back(tmp);
        }
        for(int i = 0; i < nums.size(); i++)
        {
            if(check[i] == false)
            {
                tmp.push_back(nums[i]);
                check[i] = true;
                dfs(nums, tmp);
                tmp.pop_back();
                check[i] = false;
            }
        }
    }
    vector<vector<int>> permute(vector<int>& nums) {
        dfs(nums, vector<int>());
        return ret;
    }
};